<template>
  <div v-if="src">
    <el-image
      v-if="isImage"
      :src="url"
      :preview-src-list="previewSrcList||[src]"
    />
    <vxe-button v-else href="javascript:;" status="primary" type="text" icon="el-icon-download" :title="url" @click="downloadFile()">下载</vxe-button>
  </div>
</template>

<script>
export default {
  name: 'TableImage',
  props: {
    src: {
      type: String,
      required: false,
      default: ''
    },
    isImage: {
      type: Boolean,
      required: false,
      default: true
    },
    previewSrcList: {
      type: Array,
      required: false,
      default: () => { [] }
    }

  },
  computed: {
    url() {
      return this.src + (this.isImage ? '?imageView2/0/format/webp/q/75/w/80' : '')
    }
  },
  methods: {
    downloadFile() {
      window.open(this.src, '_blank')
    }
  }

}
</script>

<style>

</style>
